package com.gp.geits.controller;

import java.util.Arrays;
import java.util.Map;

import com.gp.geits.entity.IssueEntity;
import com.gp.geits.service.IssueService;
import com.gp.geits.utils.PageUtils;
import com.gp.geits.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * 
 *
 * @author lzf
 * @date 2022-03-10 12:57:57
 */
@RestController
@RequestMapping("/issue")
public class IssueController {
    @Autowired
    private IssueService issueService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = issueService.queryPage(params);

        return R.ok().data("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		IssueEntity issue = issueService.getById(id);

        return R.ok().data("issue", issue);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody IssueEntity issue){
		issueService.save(issue);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody IssueEntity issue){
		issueService.updateById(issue);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		issueService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
